import { reqCourseList } from '@/api'

const state = {
  courselist:[]
}
const mutations = {
  COURSELIST(state,courselist){
    state.courselist = courselist;

  }
}
const actions = {
  // 获取全部课程
  async courseList({ commit },data) {
    // axios 接口函数获得的是 promise对象，async await 可以将数据处理后返回
    let result = await reqCourseList(data)

    if (result.code == 0 && result.msg=='success') {
      commit('COURSELIST', result.data.records)
    }
  },
}
const getters = {}

export default {
  namespaced: true, //命名空间是防止仓库中出现同名的情况
  state,
  mutations,
  actions,
  getters,
}
